//
//  HACStockDetailComponent.h
//  Pods
//
//  Created by Hotacool on 2017/9/5.
//
//

#import <UIKit/UIKit.h>
#import "HACFocusProvider.h"
#import "HACChartData.h"
#import "HACBasicComponents.h"

@class HACStockDetailComponent;
@protocol HACStockDetailComponentDelegate <NSObject>

- (void)stockDetailNeedRefresh:(HACStockDetailComponent*)component ;

- (void)tapedStockComponent:(HACStockDetailComponent*)component gesture:(UIGestureRecognizer*)gesture ;

- (void)dragStockComponent:(HACStockDetailComponent*)component gesture:(UIGestureRecognizer*)gesture ;
@end

@interface HACStockDetailComponent : UIView <HACFocusProvider>
@property (nonatomic, strong) HACChartData *data;
@property (nonatomic, strong, readonly) UIScrollView *contentView;
@property (nonatomic, assign) BOOL isRefresh; //刷新，load more
@property (nonatomic, strong, readonly) UIActivityIndicatorView *refreshIndicator; //load more indicator
/** 当前焦点所在index */
@property (nonatomic, assign) NSInteger focusIndex;
@property (nonatomic, assign) NSInteger focusItemsCount; /** 默认1，只绘制竖线，需要绘制横线指示设置成2 */
@property (nonatomic, strong, readonly) UILabel *xCursorLabel; // y轴的文字提示
@property (nonatomic, strong, readonly) UILabel *yCursorLabel; // x轴的文字提示
@property (nonatomic, strong, readonly) CAShapeLayer *focusLayer;

@property (nonatomic, strong, readonly) HACFocusComponents *focusComponent;
@property (nonatomic, assign) CGPoint focusPoint;
@property (nonatomic, assign) BOOL focusEnable; //是否焦点
//倒序index，K线图默认显示最新时间段K线
@property (nonatomic, assign) NSInteger indexFromEnd;
@property (nonatomic, weak) id<HACStockDetailComponentDelegate> delegate;

- (void)setUp ;
- (void)refreshWithData:(HACChartData*)data;
- (void)refreshWithIncrementData:(HACChartData*)data;
- (void)refreshUI ;
- (void)resetToLatest ;
- (void)reset;

/**
 停止刷新（scroll到最左边触发拉去最新数据，需主动调用该方法，传入最新数据）

 @param data 最新data
 */
- (void)endRefreshWithData:(HACChartData*)data;

#pragma mark -- gestures
- (void)reactForTapGesture:(UITapGestureRecognizer *)gesture ;
- (void)reactForLongPressGesture:(UILongPressGestureRecognizer*)gesture ;
- (void)reactForPinchGesture:(UIPinchGestureRecognizer *)gesture ;
- (void)reactForContentViewDidScroll:(UIScrollView *)scrollView ;

- (NSString *)stringForFocusItem:(HACFocusComponents *)focusItem focusIndex:(NSInteger)focusIndex ;
@end
